<template>
    <div class="standard">
        <RiskTableP ref="risk-table" :tableData="tableData" :tableConfig="tableConfig" :column="columns" v-loading="tableLoading"> </RiskTableP>
    </div>
</template>
<script lang="ts">
import RiskTableP from '@/common/components/risk-table-plus.vue';
import { ColumnVO, TableConfigVO } from '@/common/vo';
import { queryWarningStandardStock } from '@/project/max-wealth/pages/report/api/comprehensive-info-query';
import { numberFormat } from '@/utils/tools';
import { Component, Vue } from 'vue-property-decorator';

@Component({ name: 'StandardLack', components: { RiskTableP } })
export default class StandardLack extends Vue {
    tableConfig: TableConfigVO = {
        rowKey: 'fundName', // 主键key
        allRowKeys: [], // 所有页数据的key集合
    };
    tableData: any = [];
    tableLoading: boolean = false;
    columns: ColumnVO[] = [
        {
            title: '产品名称',
            field: 'fundName',
            align: 'left',
        },
        {
            title: '证券代码',
            field: 'stockCode',
            align: 'left',
        },
        {
            field: 'stockNameSt',
            title: '证券名称',
            align: 'left',
        },
        {
            title: '库存数量',
            field: 'currentAmount',
            align: 'right',
            render: value => numberFormat(value),
        },
        {
            title: '可用数量',
            field: 'usableAmount',
            minWidth: '120px',
            align: 'right',
            render: value => numberFormat(value),
        },
        { field: 'marketName', title: '交易市场', align: 'center' },
    ];

    // TimeSendMessage = null;
    mounted() {
        this.getList();
        // this.TimeSendMessage = setInterval(async () => {
        //     this.getList();
        // }, 60 * 1000);
    }

    // beforeDestroy() {
    //     if (this.TimeSendMessage) {
    //         this.TimeSendMessage && clearInterval(this.TimeSendMessage);
    //         this.TimeSendMessage = null;
    //     }
    // }

    // 表格数据
    getList() {
        this.tableLoading = true;
        queryWarningStandardStock()
            .then((res: any) => {
                this.tableData = res;
            })
            .catch(() => {})
            .finally(() => {
                this.tableLoading = false;
            });
    }
}
</script>
<style lang="scss" scoped>
.standard {
    margin: 5px;
    height: calc(100% - 45px);
}
</style>
